package com.bean;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractRefreshableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author wangLin
 * @version 1.0
 * @projectName spring-wl
 * @className SpringTest
 * @date 2021-03-16 周二
 * @time 10:25
 * @description TODO
 */
public class SpringTest {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");

//        方式一、1-依赖注入DI测试
        /*People people = (People) applicationContext.getBean("people");
        System.out.println(people.getName());
        System.out.println(people.getId());
        Rice rice = (Rice) applicationContext.getBean("rice");
        rice.showName();*/

//        2-带参数的依赖注入测试
        /*System.out.println("------------------------");
        User user = (User) applicationContext.getBean("user");
        System.out.println(user.getUsername());
        System.out.println(user.getId());*/

//        五个参数的user测试
       /* User user1 = (User)applicationContext.getBean("user1");
        System.out.println("Student [id=" + user1.getId() + ", name=" + user1.getUsername() + ", dream=" + user1.getDream()
                + ", score=" + user1.getScore() + ", graduation=" +"]");
*/
//        方式二、注解方式测试
        People people1 = (People) applicationContext.getBean("people1");
        people1.eat();

    }
}
